import { User } from './user.entity';
import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
@Entity()
export class Friend {
  @PrimaryGeneratedColumn()
  id: number;

  // @Column({ unique: true })
  // username: string;

  @ManyToOne(() => User, (user) => user.id)
  @JoinColumn()
  user: User;

  // @Column({ type: 'int' })
  // user: number;

  @ManyToOne(() => User, (user) => user.id)
  @JoinColumn()
  // TypeORMError: Referenced column user was not found in entity UserInfo
  follow: User;

  // @Column({ type: 'int' })
  // follow: number;

  @Column({
    default: () => 0,
  })
  state: 0 | 1;

  @Column({
    name: 'create_time',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
  })
  createTime: Date;

  @Column({
    name: 'update_time',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
  })
  updateTime: Date;
}
